<?php
// +--------------------------------------------------------------------------
// | ISDCE [ 载攸道 先顺得常 ] <http://www.zaiyoudao.com>
// +--------------------------------------------------------------------------
// | Copyright © 2009-2017 载攸道 版权所有 <TEL:086-010-57209502>
// +--------------------------------------------------------------------------
// | Project: YiPHP [ 我会的仅仅是偷懒！ ] <http://www.yiphp.com>
// +--------------------------------------------------------------------------
// | Author: 牛很多戒很多不戒 <n@isdce.com> <http://juexue.wang>
// +--------------------------------------------------------------------------

/**
 * [ API模块 ]
 */
namespace Api\Controller;
use Think\Controller;

/**
 * 信息接口
 */
class MessageController extends Controller{
	
	public function TelLoginCode(){
		
		//判断是否是ajax请求
		
			$m_sms_code = M('sms_code');
		
			//获得数据
			$data['name'] = I('param.tel');
			$data['code'] = rand(1000,9999);
			$data['time'] = time();
			
			$tel = I('param.tel');  
				
			
			$data['status'] = 2;
			
			$result = $m_sms_code->add($data);
			
			smsbao_send($tel,$data['code']);
			
			
			//die;
			//返回信息
			$info = $result?get_errcode(0):get_errcode(-1);
				
		

		$this->ajaxReturn($info);
	}
	
	public function EmailLoginCode(){
		
		//判断是否是ajax请求
		
			$m_sms_code = M('sms_code');
		
			//获得数据
			$data['name'] = I('param.email');
			$data['code'] = rand(1000,9999);
			$data['time'] = time();
			
			$email = I('param.email');  
				
			
			$data['status'] = 2;
			
			$result = $m_sms_code->add($data);
			
			$mails = new \Think\Mail();
				
			//$mail->SendMail('n@isdce.com','标题','内容','发件人');
			
			$name = '登录验证码';
			$title = '登录验证码';
			$value = $data['code'];
			$mail = I('param.email');
			
			$mails->SendMail($mail,$title,$value,$name);
			
		

			$this->ajaxReturn(get_errcode(0));
	}
}